
$(document).ready( 
		function()
		{
			$("a[tag='delete']").click( delete_pic );
			$("a[tag='changename']").click( change_pic_name );
		}
	);

function delete_pic()
{
	var params = "pid=" + $(this).attr('pid');
	var this_ = $(this);
	
	BindEvent( '#delPicBtn', 'click', function() {   
	    $.ajax(
	  	{
	  		type: 'post',
	        url: edp_domain_url + 'ajax_delete_pic/?tiny=2',
	        data: params,
			timeout: 5000,
			global:false,
		    beforeSend: function()
		    {
	  			SimpleMessage( '正在删除...', null );
			},
			error: function()
			{
				SimpleMessage( '删除失败(0)...', 1000 );
			},
			success: function( data )
	        {
				/*
				if( data != "0" )
				{
					MessageBox( data, true );
				}
				else
				{
					UnblockUI( 500 );
					this_.closest('.pic_item_box').css("display", "none");
				}
				*/
				$.blockUI(
						{
							message: data,
							css: { padding:'5px',color:'#CC0000'}
						});
	        },
	        complete: function()
            {
            	$.unblockUI();
            	window.location.reload();
            }
	       
	    });
   	 });
   	 
   ShowModelDialog( "#delPicBox"  );
   	 
}



function change_pic_name()
{
	 var piclink = $(this);
	
	 BindEvent( '#msgboxok', 'click', function() {
		
		var params = "name=" + $("#changedname").val()  + "&pid=" + piclink.attr('pid');
		 $.ajax(
				  	{
				  		type: 'post',
				        url: edp_domain_url + 'ajax_change_name/?tiny=2',
				        data: params,
						timeout: 5000,
						global:false,
					    beforeSend: function()
					    {
				  			SimpleMessage( '正在发送改名请求...', null );
						},
						error: function()
						{
							SimpleMessage( '改名失败，稍后再试...', 1000 );
						},
						success: function( data, textStatus )
				        {
							if( data != "0" )
								MessageBox( data, null );
							else
							{
								piclink.parent().siblings().filter("span[tag=picname]").text( $("#changedname").val() );
								SimpleMessage( '改名成功！', 1000 );
								
							}
				        }
				       
		 });
		  
		
	 });
	 
	 ShowModelDialog( "#msgbox" );
	
}

$(document).ready(function(){
  
	
	$("#btnShowCate").toggle(function(){
   	    $("#hiddenCate").show();
   		$(this).removeClass("mr");
		$(this).addClass("lt");
		$(this).html("折起");
	},function(){
	   	$("#hiddenCate").hide();
   		$(this).removeClass("lt");   
		$(this).addClass("mr");
		$(this).html("显示更多");
	});    
	   
});